<%@page import="java.util.ArrayList" %>
<!DOCTYPE html>
<html>
<head>
<title>Second Home Inc.</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
  <div id="page-wrap" align="center">
    <div >
      <a href="index.jsp"><img src="images/banner.png" alt="Second Home Inc."></a>
    </div>
    <nav>
      <ul>
        <li><a href="index.jsp">Home</a>
          <ul>
            <li><a href="#">About</a></li>
            <li><a href="#">Contact Us</a></li>
          </ul></li>
        <li><a href="#">Reservation Management</a>
          <ul>
            <li><a href="controller?&source=createRes">Create Reservation</a></li>
            <li><a href="controller?&source=viewRes">View Reservations</a></li>
          </ul></li>
        <li><a href="controller?&source=acctManagement">Account Management</a></li>
        <%
          if ( request.getSession().getAttribute("user") == null )
            out.write("        <li><a href=\"index.jsp\">Login</a></li>");
          else
            out.write("        <li><a href=\"controller?&source=logout\">Logout</a></li>");
        %>
      </ul>
    </nav>
    <br />
    <%
      ArrayList<String> errors = (ArrayList<String>) request.getAttribute("errors");
      if (errors != null && errors.size() > 0)
      {
        out.write("<div style=\"color:red\">");
        out.write("<table ><tr><td>");
        out.write("Please correct the following errors:<br /><br />");

        for (String error : errors)
        {
          out.write("" + error + "<br />");
        }
        out.write("<br /></td></tr></table>");
        out.write("</div>");
      }
    %>
    <table class="main" title="Content" id="content">
      <tr>
        <td>
          <form name="registerForm" action="controller?&source=register" method=POST>
          <table class="register">
            <tr><td>Create Account:</td></tr>
            <tr>
              <td>E-mail:</td>
              <td><input type="TEXT" name="reg_email" value="<%= request.getParameter("reg_email") == null ? "" : request.getParameter("reg_email") %>"> <br /></td>
            </tr>
            <tr>
              <td>E-mail again:</td>
              <td><input type="TEXT" name="reg_email2" value="<%= request.getParameter("reg_email2") == null ? "" : request.getParameter("reg_email2") %>" autocomplete="off"> <br /></td>
            </tr>
            <tr>
              <td>Password:</td>
              <td><input type="PASSWORD" name="reg_password" value="<%= request.getParameter("reg_password") == null ? "" : request.getParameter("reg_password") %>"> <br /></td>
            </tr>
            <tr>
              <td>Password again:</td>
              <td><input type="PASSWORD" name="reg_password2" value="<%= request.getParameter("reg_password2") == null ? "" : request.getParameter("reg_password2") %>"> <br /></td>
            </tr>
            <tr><td><br /></td></tr>
            <tr>
              <td>First Name:</td>
              <td><input type="TEXT" name="reg_firstName" value="<%= request.getParameter("reg_firstName") == null ? "" : request.getParameter("reg_firstName") %>"> <br /></td>
            </tr>
            <tr>
              <td>Last Name:</td>
              <td><input type="TEXT" name="reg_lastName" value="<%= request.getParameter("reg_lastName") == null ? "" : request.getParameter("reg_lastName") %>"> <br /></td>
            </tr>
            <tr>
              <td>Phone Number:</td>
              <td><input type="TEXT" name="reg_phoneNumber" value="<%= request.getParameter("reg_phoneNumber") == null ? "" : request.getParameter("reg_phoneNumber") %>" maxlength="12" style="width: 7em;"> <br /></td>
            </tr>
  					<tr><td><br /></td></tr>
            <tr>
              <td>Address:</td>
              <td><input type="TEXT" name="reg_address1" value="<%= request.getParameter("reg_address1") == null ? "" : request.getParameter("reg_address1") %>"> <br /></td>
            </tr>
            <tr>
              <td></td>
              <td><input type="TEXT" name="reg_address2" value="<%= request.getParameter("reg_address2") == null ? "" : request.getParameter("reg_address2") %>"> <br /></td>
            </tr>
            <tr>
              <td></td>
              <td><input type="TEXT" name="reg_address3" value="<%= request.getParameter("reg_address3") == null ? "" : request.getParameter("reg_address3") %>"> <br /></td>
            </tr>
            <tr>
              <td>City:</td>
              <td><input type="TEXT" name="reg_city" value="<%= request.getParameter("reg_city") == null ? "" : request.getParameter("reg_city") %>"> <br /></td>
            </tr>
            <tr>
              <td>State:</td>
              <td>
                <select name="reg_state">
								  <option value="AL"<% if ( "AL".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>AL</option>
									<option value="AK"<% if ( "AK".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>AK</option>
									<option value="AZ"<% if ( "AZ".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>AZ</option>
									<option value="AR"<% if ( "AR".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>AR</option>
								  <option value="CA"<% if ( "CA".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>CA</option>
									<option value="CO"<% if ( "CO".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>CO</option>
									<option value="CT"<% if ( "CT".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>CT</option>
									<option value="DC"<% if ( "DC".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>DC</option>
									<option value="DE"<% if ( "DE".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>DE</option>
									<option value="FL"<% if ( "FL".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>FL</option>
				 					<option value="GA"<% if ( "GA".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>GA</option>
									<option value="HI"<% if ( "HI".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>HI</option>
									<option value="ID"<% if ( "ID".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>ID</option>
									<option value="IL"<% if ( "IL".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>IL</option>
									<option value="IN"<% if ( "IN".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>IN</option>
									<option value="IA"<% if ( "IA".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>IA</option>
									<option value="KS"<% if ( "KS".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>KS</option>
									<option value="KY"<% if ( "KY".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>KY</option>
									<option value="LA"<% if ( "LA".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>LA</option>
									<option value="ME"<% if ( "ME".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>ME</option>
									<option value="MD"<% if ( "MD".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>MD</option>
									<option value="MA"<% if ( "MA".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>MA</option>
									<option value="MI"<% if ( "MI".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>MI</option>
									<option value="MN"<% if ( "MN".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>MN</option>
									<option value="MS"<% if ( "MS".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>MS</option>
									<option value="MO"<% if ( "MO".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>MO</option>
									<option value="MT"<% if ( "MT".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>MT</option>
									<option value="NE"<% if ( "NE".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>NE</option>
									<option value="NV"<% if ( "NV".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>NV</option>
									<option value="NH"<% if ( "NH".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>NH</option>
									<option value="NJ"<% if ( "NJ".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>NJ</option>
									<option value="NM"<% if ( "NM".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>NM</option>
									<option value="NY"<% if ( "NY".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>NY</option>
									<option value="NC"<% if ( "NC".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>NC</option>
									<option value="ND"<% if ( "ND".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>ND</option>
									<option value="OH"<% if ( "OH".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>OH</option>
								  <option value="OK"<% if ( "OK".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>OK</option>
									<option value="OR"<% if ( "OR".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>OR</option>
									<option value="PA"<% if ( "PA".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>PA</option>
									<option value="RI"<% if ( "RI".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>RI</option>
									<option value="SC"<% if ( "SC".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>SC</option>
									<option value="SD"<% if ( "SD".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>SD</option>
									<option value="TN"<% if ( "TN".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>TN</option>
									<option value="TX"<% if ( "TX".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>TX</option>
									<option value="UT"<% if ( "UT".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>UT</option>
									<option value="VT"<% if ( "VT".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>VT</option>
									<option value="VA"<% if ( "VA".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>VA</option>
									<option value="WA"<% if ( "WA".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>WA</option>
									<option value="WV"<% if ( "WV".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>WV</option>
									<option value="WI"<% if ( "WI".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>WI</option>
								  <option value="WY"<% if ( "WY".equals(request.getParameter("reg_state")) ) out.write(" selected=\"selected\"");%>>WY</option>
							  </select><br />
              </td>
            </tr>
            <tr>
              <td>Zip Code:</td>
              <td><input type="TEXT" name="reg_zip" value="<%= request.getParameter("reg_zip") == null ? "" : request.getParameter("reg_zip") %>" maxlength="10" style="width: 6em"> <br /></td>
            </tr>
            <tr><td><br /></td></tr>
            <tr>
              <td></td>
              <td style="float:right;">
                <input type="SUBMIT" name="registerButton" value="Create Account">
              </td>
            </tr>
          </table>
          </form>
        </td>
      </tr>
    </table>
  </div>
</body>
</html>